<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function getTypeComplete(value) {
        return Object.prototype.toString
          .call(value) // [object Undefined]
          .match(/\s+(\w+)/)[1] // Undefined
          .toLowerCase() // undefined
      }

      function isEmptyComplete(v) {
        switch (this.getTypeComplete(v)) {
          case 'null':
          case 'undefined':
            return true
          case 'string':
            if (v.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true
            break
          case 'boolean':
            if (!v) return true
            break
          case 'number':
            if (0 === v || isNaN(v)) return true
            break
          case 'object':
            if (null === v || v.length === 0) return true
            for (const i in v) {
              return false
            }
            return true
          case 'map':
            console.log(v)
            if (v.size === 0) {
              return true
            }
            return false
          case 'array':
            if (v.length === 0) {
              return true
            }
            return false
          case 'set':
            if (v.size === 0) {
              return true
            }
            return false
        }
        return false
      }

      function objPropIsEmpty(obj, prop) {
        if (!obj.hasOwnProperty(prop)) {
          return true
        }
        return isEmptyComplete(obj[prop])
      }
      let obj = { name: 'null' }
      console.log(objPropIsEmpty(obj, 'name'))
    </script>
  </body>
</html>
